<div class="fsh-pop">
    <div id="add_form" class="layui-form">
        <table id="tags" class="layui-hide" lay-filter="tags"></table>
    </div>
</div>
<script>


    layui.use(['layer', 'table'], function () {
        var openIds = '<%=openId%>';
        var layer = layui.layer;
        var table = layui.table;
        var fansArr=[];
        var tableObj = table.render({
            id: 'tags',
            elem: '#tags',
            url: '../userTag/listForPage',
            align: "center",
            cols: [[ //表头
                {type: 'numbers', title: '编号',width:50},
                {field:'id', title: '标签编号',width:150,align: 'center'},
                {field: 'name', title: '标签名称', width: 150, align: 'center'},
                {
                    field: 'lock', title: '操作', width: 300, align: 'center', templet: function (d) {
                        return '<a href="javascript:;" class="font-primary" lay-event="showTag">绑定标签</a>' ;
                    }, unresize: true, align: 'center'
                }
            ]],
        });

        //表格内部操作按钮监听
        table.on('tool(tags)', function (obj) { //注：tool是工具条事件名，mainList是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            // 同步粉丝
            if (layEvent === 'showTag') {
                $.ajax({
                    url: '../accountfans/batchCreateTagging',
                    data:{openIds:openIds,tagId:data.id},
                    success: function (result) {
                        if (result.success) {
                            parent.layer.closeAll();
                            layer.msg("绑定成功");
                        }
                    },
                    error: function () {
                        parent.layer.closeAll();
                        layer.msg("绑定失败");
                    }
                })
            }
        });
    });

</script>